package gek.uni.diplom.ocl.example.patterns.hierarhical;


import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public abstract class ACodeNode implements IPattern{
  private String oclString;
  private IPattern parent = null;
  private List<IPattern> children = new ArrayList<IPattern>();
  private Set<String> importStrings = new HashSet<String>();

  public ACodeNode(String oclString, IPattern parent){
    this.oclString = oclString;
    setParent(parent);
  }
  
  @Override
  public void addChild(IPattern child) {
    children.add(child);
  }

  @Override
  public List<IPattern> getChildren() {
    return children;
  }

  @Override
  public String getOclString() {
    return oclString;
  }

  @Override
  public IPattern getParent() {
    return parent;
  }

  @Override
  public void setOclString(String oclString) {
    this.oclString = oclString;
  }

  @Override
  public void setParent(IPattern parent) {
    this.parent = parent;
    if (parent != null)
      parent.addChild(this);
  }
  
  @Override
  public void addImportString(String importString) {
    importStrings.add(importString);
  }

  @Override
  public void addImportStrings(Collection<String> importStrings) {
    importStrings.addAll(importStrings);
  }

  @Override
  public Collection<String> getImportStrings() {
    return importStrings;
  }
}
